class Solution(object):
    def maxMatrixSum(self, matrix):
        m = len(matrix)
        n = len(matrix[0])
        zhengshu = []
        fushu = []
        for i in range(m):
            for j in range(n):
                if matrix[i][j] >= 0:
                    zhengshu.append(matrix[i][j])
                else:
                    fushu.append(matrix[i][j])
        if len(fushu) % 2 == 0:
            return sum(zhengshu) - sum(fushu)
        else:
            ans = sum(zhengshu) - sum(fushu)
            fu = max(fushu)
            if len(zhengshu):
                zheng = min(zhengshu)
                ans = max(ans - 2 * zheng, ans + 2 * fu)
            else:
                ans = ans + 2 * fu
            return ans


